/**
 * @param {string} s
 * @param {string} t
 * @return {boolean}
 */
var backspaceCompare = function(s, t) {
  const filter = (str)=>{
    let nums = str.split('')
    let k = 0
    for(let i = 0;i < nums.length;i++){
      if(nums[i] !== '#'){
        nums[k] = nums[i]
        k++
      }else{
        k--
        if(k < 0) k = 0
      }
    }
    return nums.splice(0,k).join('')
  }
  console.log(filter(s));
  console.log(filter(t));
  
  return filter(s) === filter(t)
};
console.log(backspaceCompare("y#fo##f"
,"y#f#o##f"));